{% extends 'eform_base_no_nav.html' %}
{% load static %}

{% block title %}
    <title>Eform</title>
{% endblock title %}
    

{% block body %}
<a class="gnslogo p-3" href="{% url 'workstation_wo' wo %}" >
    <img src="{% static 'cews_static/css/media/Corporate_logo.png' %}">
</a>
<div class="container-fluid mt-3">
    <div class="card bg-secondary">
        {% if showall %}
            <a class="btn btn-sm btn-outline-success" href="?&showall=false" role="button">Show Preset Forms</a>
        {% else %}
            <a class="btn btn-sm btn-outline-success" href="?&showall=true" role="button">Show All Forms</a>
        {% endif %}
        <div class="card-header">
            <h1>Please "Select" one of below E-Form schema to start the E-Form filing</h1>
        </div>

        <div class="p-2">
            <form class="d-inline d-none" method="get" action="{% url 'eform:eformRoutingView' workOrder_id %}">
                <input type="hidden" name="search_wo_id" value="{{workOrder_id}}">
                <input type="hidden" name="showall" value="{{showall}}">
                <div class="row">
                    <div class="col-auto">
                        {{searcheform.as_p}}
                    </div>
                    <div class="col">
                        <button type="submit" name="searcheform" class="btn btn-sm btn-outline-success">SEARCH</button>
                    </div>
                </div>
            </form>
        </div>

        <div class="card-body">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <!-- <th>Form ID</th> -->
                        <th>Form No</th>
                        <th>Ref.</th>
                        <th>Form Title</th>
                        <th>Last Update</th>
                        <th>Endorsed Require</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
           
                    
                    {% for e in eforms %}
                        <tr 
                        {% if e.pk == new %}
                            class="table-success"
                        {% endif %}
                            >
                            <!-- <td class="pt-4">{{e.id}}  </td> -->
                            <td class="pt-4">{{e.formNo}}  </td>
                            <td class="pt-4">{{e.ref}} </td>
                            <td class="pt-4">{{e.title}}</td>
                            <td class="pt-4">{{e.updated|date:"Y-m-d H:i"}}</td>
                            <td class="pt-4">
                            {% if e.endorsor_require %}
                                Yes
                            {% else %}
                                No
                            {% endif %}
                                </td>
                            <td class="pt-3">
                                <div class="td-wrapper">
                                    
                                    <a name="" id="" data-sid="{{e.pk}}" data-title="{{e.title}}"  class="create-form-btn btn btn-sm btn-outline-success" href="#" role="button">Select</a>
                                    <!-- <a href="{% url 'eform:schemaBuilder' e.pk %}">Edit</a> -->
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                        
                </tbody>
            </table>
        </div>
    </div>
</div>


<!-- Modal -->
<div class="modal fade mx-auto" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Confirm</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
            </div>
            <div class="modal-body" >
                <p id="confirm-body"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                <button type="button" id="btn-confirm" class="btn btn-primary">Yes</button>
            </div>
        </div>
    </div>
</div>
<form class="d-inline d-none" id="createForm" method="post" action="{% url 'eform:eformNewSchema' %}">
    {% csrf_token %}
    <input type="hidden" name="eformSchema_id" id="eformSchema_id" value="">
    <input type="hidden" name="wo_id" id="workOrder_id" value="{{workOrder_id}}">
</form>
{% endblock body %}


{% block script %}
<script src="{% static 'eform/chooseForm.js' %}"></script>
{% endblock script %}
    

    